
<link rel="stylesheet"  href="__ADMIN__/css/cms.css">
<style>
.panel-body{background: #e5e5e5}
.status{display: none}
.col-md-3:hover .status{display: block;}
</style>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
	
	<!-- END RIBBON -->
	<div class="content">
		<div class="panel panel-default panel-intro">
			<div class="panel-heading">
				<div class="panel-lead">
					<em>CMS - 项目列表</em>
                    注意：双击项目，可进行视图view切换
				</div>
			</div>
			<div class="panel-body">
				<div id="myTabContent" class="tab-content">
					<div class="tab-pane fade active in" id="one">
						<div class="widget-body no-padding">
							<div class="bootstrap-table">
								
								<div class="fixed-table-toolbar">
									<div class="bs-bars pull-left">
										<div id="toolbar" class="toolbar">
											<a href="javascript:window.location.reload();" class="btn btn-primary btn-refresh" title="刷新">
												<i class="fa fa-refresh"></i>
											</a>
											{if condition="$adminController->vif('item','add')"}
											<a href="javascript:add('{:url('add')}');" class="btn btn-success btn-add" title="添加"><i class="fa fa-plus"></i> 添加</a>
											{/if}
											{if condition="$adminController->vif('item','decompose')"}
												<input type="file" name="file" id="file" data-status='1' onchange="fileUpload()" style="display:none" accept=".zip">
												<a href="javascript:select_file();" target="_blank" data-type="full" class="btn btn-danger btn-download"><i class="fa fa-download"></i> 导入项目</a>
											{/if}
										</div>
									</div>
									<div class="columns columns-right btn-group pull-right">
                                        <button class="btn btn-default clickTab" type="button" name="toggle" aria-label="toggle" title="搜索菜单">
											<i class="glyphicon glyphicon-list-alt icon-list-alt"></i>
										</button>
									</div>
								</div>
								<div class="fixed-table-container" style="padding-bottom: 0px;">
									<div class="fixed-table-body">
										<div class="wxapp-container">
											<div class="row">
												
												{foreach name="list" item="v"}
												<div class="col-md-3" data-id="{$v.i_id}">
													<div class="item wow bounceInLeft" style="visibility: visible; animation-name: bounceInLeft;position:relative">
														<div class="status" style="position: absolute;right: 0px;top: 0px;background: #f5f5f5;{if condition="$v['i_status']==1"}display: block{/if}">
															<img src="__ADMIN__/images/gou.png">
														</div>
														<figure><img src="{$v.i_logo}" alt="Image" class="img-responsive"></figure>
														<div class="text">
															<h3>{$v.i_name}</h3>
															<div class="meta">{$v.i_author} - {$v.i_add_time|date='Y-m-d', ###}</div>
															<p>{$v.i_des}</p>
														</div>
														<div class="action">
															{if condition="$adminController->vif('item','export')"}
																<a href="javascript:_export('{:url('export', ['id'=>$v['i_id']])}', '{$v.i_path}');" class="btn btn-info"> 导出</a>
															{/if}
															{if condition="$adminController->vif('item','upd')"}
																<a href="javascript:upd('{:url('upd', ['id'=>$v['i_id']])}');" class="btn btn-success btn-experience">修改</a>
															{/if}

															{if condition="$adminController->vif('item','delete')"}
																<a href="javascript:del('{:url('delete', ['id'=>$v['i_id']])}');" class="btn btn-danger btn-download">删除</a>
															{/if}
														</div>
													</div>
												</div>
												{/foreach}
				
											</div>
										</div>
									</div>
									<div class="fixed-table-pagination" style="display: block;">
										<div class="pull-left pagination-detail">
											{$page}
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>


<!--多功能面板--> 
<div id="divTab" class="divTab">
    <!--固定头部-->
    <div class="jzy_tab_top">
        <img src="__ADMIN__/images/gongneng.png" class="lt">
        <div class="txt lt">功能面板</div>
        <div class="on rt" id="onTab">×</div>
    </div>
    
    <div class="jzy_tab_main">
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;"><legend>搜索条件</legend></fieldset>
        <form class="layui-form" action="">
            <div class="layui-form-item">
                <div class="layui-inline">
                <label class="layui-form-label">作者</label>
                <div class="layui-input-inline">
					<input type="text" class="form-control" name="nick" value="{$page_where.nick}">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                <label class="layui-form-label">项目名称</label>
                <div class="layui-input-inline">
                    <input type="text" class="form-control" name="name" value="{$page_where.name}">
                </div>
			</div>
			
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn layui-btn-sm layui-btn-normal">搜索</button>
                </div>
            </div>
        </form>
    </div>
</div>
<script>
layui.use(['form'], function(){
  var form = layui.form;
});
// 导入项目
function select_file(){
	var status = $('#file').attr('data-status');
	if (status == 1) {
		$('#file').attr('data-status', 0);
		$("#file").trigger("click");
	} else {
		$.thinkmimi({Content : '系统正在导入中~', Type:2, Align:'right', OutTime:2000});
	}
}
function fileUpload(){
	$.thinkmimi({Content : '项目导入中，请勿刷新当前页面~', Type:1, Align:'right', OutTime:2000});

    var formData = new FormData();
    formData.append('file', $('#file')[0].files[0]);
    $.ajax({
		url : '{:url("decompose")}',
		type : 'POST',
		data : formData,
		contentType: false,// 当有文件要上传时，此项是必须的，否则后台无法识别文件流的起始位置
		processData: false,// 是否序列化data属性，默认true(注意：false时type必须是post)
		clearForm: true,//提交后是否清空表单数据
		success: function(data) {
			var array = eval('('+data+')');
			$('#file').attr('data-status', 1);
			
			if (array['code'] == '01') {
				$.thinkmimi({Content : array['msg'], Type:2, Align:'right', OutTime:2000});
			} else {
				$.thinkmimi({Content : array['msg'], Type:1, Align:'right', OutTime:2000});
				window.setTimeout(function(){
					window.location.reload();
				}, 700);
			}
		},
		error: function(data, status, e) {
			$('#file').attr('data-status', 1);
			$.thinkmimi({Content : '服务器异常', Type:2, Align:'right', OutTime:2000});
		}
	});
}
// 删除项目
function del(href) {
	if (confirm('确认删除吗？')==true){
		$.ajax({
			type: 'post',
			data: {},
			url: href,
			success: function(data) {
				var array = eval('('+data+')');
				if (array['code'] == '01') {
					$.thinkmimi({Content : array['msg'], Type:2, Align:'right', OutTime:2000});
				} else {
					$.thinkmimi({Content : array['msg'], Type:1, Align:'right', OutTime:2000});
					window.setTimeout(function(){
						window.location.reload();
					}, 700);
				}
			}
		});
	}
}
// 导出项目
function _export(href,path) {
	$.ajax({
		type: 'post',
		data: {},
		url: href,
		success: function(data) {
			var array = eval('('+data+')');
			if (array['code'] == '01') {
				$.thinkmimi({Content : array['msg'], Type:2, Align:'right', OutTime:2000});
			} else {
				$.thinkmimi({Content : array['msg'], Type:1, Align:'right', OutTime:2000});
				window.setTimeout(function(){
					window.location.href = href+'?path='+path;
				}, 500);
			}
		}
	});
}
// 切换项目
$('.col-md-3').dblclick(function(){
	var id = $(this).attr('data-id');
	$.ajax({
		type: 'post',
		data: {'id':id},
		url: "{:url('status')}",
		success: function(data) {
			var array = eval('('+data+')');
			if (array['code'] == '01') {
				$.thinkmimi({Content : array['msg'], Type:2, Align:'right', OutTime:2000});
			} else {
				$.thinkmimi({Content : array['msg'], Type:1, Align:'right', OutTime:2000});
				window.setTimeout(function(){
					window.location.reload();
				}, 700);
			}
		}
	});
})
// 添加
function add(href) {
	layer.open({
		type: 2,
		title: '创建新项目',
		shadeClose: true,
		shade: false,
		maxmin: true,
		area: ['750px', '100%'],
		btn: ['确认', '取消'],
		content: href,
		yes: function(index, layero) {
			var _this = layero.find('iframe')[0];
			var bool  = _this.contentWindow.doSubimt();
			if (bool !== false) {
				$.thinkmimi({Content : bool['msg'],Type : 1,Align:'right',OutTime:2000,});
				menu_run();
				layer.closeAll();
				window.setTimeout(function(){
					window.location.reload();
				}, 700);
			}
		},
	});
}
// 修改
function upd(href) {
	layer.open({
		type: 2,
		title: '修改项目',
		shadeClose: true,
		shade: false,
		maxmin: true,
		area: ['750px', '100%'],
		btn: ['确认', '取消'],
		content: href,
		yes: function(index, layero) {
			var _this = layero.find('iframe')[0];
			var bool  = _this.contentWindow.doSubimt();
			if (bool !== false) {
				$.thinkmimi({Content : bool['msg'],Type : 1,Align:'right',OutTime:2000,});
				menu_run();
				layer.closeAll();
				window.setTimeout(function(){
					window.location.reload();
				}, 700);
			}
		},
	});
}
</script>
